//
//  MXMessageListCell.m
//  HNBaseProject
//
//  Created by xujie on 2024/6/5.
//

#import "MXMessageListCell.h"

@implementation MXMessageListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}

- (void)createUI {
    self.selectionStyle = 0;
    self.backgroundColor = [UIColor whiteColor];
    self.logo = [[UIImageView alloc] initWithFrame:CGRectMake(22, 10, 44, 44)];
    self.logo.image = [UIImage imageNamed:@"sys_notice"];
    [self.contentView addSubview:self.logo];
    
    self.titleLab = [[UILabel alloc] init];
    self.titleLab.text = @"家庭共享";
    self.titleLab.textColor = [UIColor colorWithHexString:@"#000000"];
    self.titleLab.font = PFRFontMedium(16);
    [self.contentView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(10);
        make.left.mas_equalTo(self.logo.mas_right).offset(20);
    }];
    
    self.subLab = [[UILabel alloc] init];
//    self.subLab.text = @"用户43799邀请你加入我的家";
    self.subLab.textColor = [UIColor colorWithHexString:@"#000000"];
    self.subLab.font = PFRFont(14);
    self.subLab.numberOfLines = 0;
    [self.contentView addSubview:self.subLab];
    [self.subLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLab.mas_bottom).offset(5);
        make.left.mas_equalTo(self.logo.mas_right).offset(20);
        make.right.offset(-5);
    }];
    
    self.timeLab = [[UILabel alloc] init];
//    self.timeLab.text = @"刚刚";
    self.timeLab.textColor = [UIColor colorWithHexString:@"#a2a2a2"];
    self.timeLab.font = PFRFont(14);
    [self.contentView addSubview:self.timeLab];
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.titleLab);
        make.right.offset(-22);
    }];
    
    self.line = [[UIView alloc] init];
    self.line.backgroundColor = [UIColor colorWithHexString:@"#f4f4f4"];
    [self.contentView addSubview:self.line];
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.logo.mas_right).offset(20);
        make.right.offset(-22);
        make.bottom.offset(0);
        make.height.mas_equalTo(1);
        make.top.equalTo(self.subLab.mas_bottom).offset(5);
    }];

    self.dotView = [[UIView alloc] init];
    self.dotView.backgroundColor = [UIColor colorWithHexString:@"#c73126"];
    self.dotView.layer.cornerRadius = 5;
    self.dotView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.dotView];
    [self.dotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.mas_equalTo(10);
        make.top.mas_equalTo(self.logo.mas_top).offset(0);
        make.right.mas_equalTo(self.logo.mas_right).offset(-5);
    }];
    
}

- (void)reloadCellWithModel:(MXNoticeListModel *)model {
    self.titleLab.text = model.appNotice.noticeTitle;
    self.timeLab.text = model.appNotice.createTime;
    self.subLab.text = model.appNotice.noticeContent;
    if (model.appNotice.noticeStatus==1)
    {
        self.dotView.hidden = YES;
    }
    else{
        self.dotView.hidden = NO;
    }
}

@end
